package com.singlemountaintech.haogongjiang.qfd;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.support.multidex.MultiDex;

import com.singlemountaintech.haogongjiang.BuildConfig;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

public class SoleMountainApp extends Application {
    private static SoleMountainApp mInstance;
    private static Context mContext;
    private RefWatcher mRefWatcher;
    private static Handler handler;
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        mContext = getApplicationContext();
        handler = new Handler();
        mRefWatcher = BuildConfig.DEBUG ?  LeakCanary.install(this) : RefWatcher.DISABLED;
    }

    /**
     * 获取全局的Handler对象
     */
    public static Handler getHandler() {
        return handler;
    }

    public static Context getContextObject() {
        return mContext;
    }

    public static SoleMountainApp getInstance() {
        return mInstance;
    }

    public static RefWatcher getRefWatcher() {
        return getInstance().mRefWatcher;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
